Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add tag to log api #92

Merged
merged 4 commits into from
Oct 10, 2023
Merged

Feat/add tag to log api #92

merged 4 commits into from
Oct 10, 2023

Conversation


export async function POST(
req: Request,
{ params }: { params: { id: string } },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice for readability for this to be typed outside e.g type QueryParams = { id : string } and then you could us it like { params : QueryParams}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but maybe thats just my preference :P

req: Request,
{ params }: { params: { id: string } },
) {
const json = await req.json();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can .json here throw? What happens?

{ params }: { params: { id: string } },
) {
const json = await req.json();
const tagId = json.tagId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const tagId = json.tagId;
const { tagId } = json;

const json = await req.json();
const tagId = json.tagId;
try {
await LogsData.connectTag(params.id, tagId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a while to work out what this meant - naming is tough :( Perhaps being more explicit with something like connectTagToLog is worth it? Not sure

try {
await LogsData.connectTag(params.id, tagId);
} catch (error) {
return NextResponse.json({ error: error }, { status: 500 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't catch it, would this not be the default behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it only return a response with status 500, but no error message. It doesn't seem like an error message shows in the console either.

@clairesquires clairesquires merged commit e3e1af8 into main Oct 10, 2023
1 check passed
@clairesquires clairesquires deleted the feat/addTagToLogAPI branch October 10, 2023 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants